
try{
	var newBtn = document.getElementById("newBtn");
	newBtn.onclick = function() { go2write(); }
} catch(e){}  // 새글쓰기 - 입력완료 버튼

try{
	var writeBtn = document.getElementById("writeBtn");
	writeBtn.onclick = function() { go2writeok(); }
} catch(e) {}

try{
	var delBtn = document.getElementById("delBtn");
	delBtn.onclick = function() { go2delete(); }
} catch(e) {} // 삭제하기 버튼

try{
	var updBtn = document.getElementById("updBtn");
	updBtn.onclick = function() { go2update(); }
} catch(e) {} // 수정하기 버튼

try{
	var updokBtn = document.getElementById("updokBtn");
	updokBtn.onclick = function() { go2updateok(); }
} catch(e) {} // 수정하기 버튼

try{
	var listBtn = document.getElementById("listBtn");
	listBtn.onclick = function() { go2list(); }
} catch(e) {} // 목록보기 버튼

function go2write() { location.href="write.jsp"}

function go2update() { 
	
		var bdno=document.getElementById('bdno').value;
		location.href="update.jsp?bdno="+bdno;

}
function go2list() { location.href="list.jsp"}

function go2delete() { 
	if( confirm("삭제하시겠습니까?")){
		var bdno= document.getElementById('bdno').value;
		location.href="delete.jsp?bdno="+bdno;
	}
//	location.href="list.jsp";
}

function go2updateok() { 
	if( confirm("수정하시겠습니까?")){
		var bdno= document.getElementById('bdno').value;
		var updatefrm= document.getElementById('updatefrm');
		updatefrm.action = "updateok.jsp?bdno="+bdno;
		updatefrm.method = "post";
		updatefrm.submit();
	}
}

function go2writeok() {
	var writefrm = document.getElementById("writefrm");
	var bdtitle = document.getElementById("bdtitle");
	var userid = document.getElementById("userid");
	var bdcontents = document.getElementById("bdcontents");
	
	
	if(bdtitle.value == "") {
		alert('제목을 기입하세요!!');
	} else if(userid.value == ""){
		alert('작성자를 입력하세요!!');
	} else if(bdcontents.value == "") {
		alert('내용을 입력하세요!!');
	} else {
		writefrm.action = "writeok.jsp";
		writefrm.method = "post";
		writefrm.submit();
	}
	


}







